Skip to content

gh-145587: fix busy loop in multiprocessing.connection.wait on Windows#145597

Open
Shrey-N wants to merge 3 commits intopython:mainfrom
Shrey-N:145587
Open

gh-145587: fix busy loop in multiprocessing.connection.wait on Windows#145597
Shrey-N wants to merge 3 commits intopython:mainfrom
Shrey-N:145587

Conversation

@Shrey-N
Copy link
Contributor

@Shrey-N Shrey-N commented Mar 6, 2026

On Windows, multiprocessing.connection.wait returns immediately if the object_list is empty, regardless of the timeout.

This fix adds a check to make sure the function actually sleeps for the duration of the timeout, matching the Unix behavior and stopping the 100% CPU usage spike.

Verified locally:-

import time
from multiprocessing.connection import wait
start = time.time()
wait([], 1.0) # took 0s before, now takes 1
print(time.time() - start)

Fixes #145587

…Windows

Ensure wait() blocks for the specified timeout when object_list is empty, preventing 100% CPU usage. This aligns the Windows behavior with the Unix implementation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

multiprocessing.connection.wait high CPU load with empty object_list

1 participant